package com.kcl.dfss.adapter;

import java.util.HashMap;
import java.util.List;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.TextView;

import com.kcl.dfss.R;

public class PersonalSetAdapter2 extends BaseAdapter {

	private static final String tag = "PersonalSetAdapter2";
	private List<HashMap<String, String>> list;
	private Context context;
	private int type[];
	
	public PersonalSetAdapter2(List<HashMap<String, String>> list,Context context,int type[]) {
		this.list = list;
		this.context = context;
		this.type = type;
	}
	
	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater mInflater = LayoutInflater.from(context);
		View view = null;
		if(type[position]==0){
			view = mInflater.inflate(R.layout.pset_item1, null);
			String content = list.get(position).get("data2");
			
			Log.i(tag, content+"this is contnet");
			
			TextView text1 = (TextView) view.findViewById(R.id.text_model);
			CheckBox check_model = (CheckBox) view.findViewById(R.id.check_model);
			if(content.equals("新手模式")){
				check_model.setBackgroundResource(R.drawable.check_state);
			}else if(content.equals("老手模式")){
				check_model.setBackgroundResource(R.drawable.check_state);
			}else if(content.equals("运动模式")){
				check_model.setBackgroundResource(R.drawable.check_state);
			}
			text1.setText(content);
		}else{
			view = mInflater.inflate(R.layout.pset_item2, null);
			String name1 = list.get(position).get("data2");
			Log.i(tag, name1+"this is name1");
			TextView text3 = (TextView) view.findViewById(R.id.text_details);
			text3.setText(name1);
		}
		return view;
	}

}
